export const getToken = () => localStorage.getItem('token')
export const getRole = () => localStorage.getItem('role')
export const getUsername = () => localStorage.getItem('username')
export const getUserId = () => localStorage.getItem('userId')

export const isAdmin = () => getRole() === 'admin'

export const clearAuth = () => {
  localStorage.clear()
}

export const hasPermission = (requiredRole) => {
  const userRole = getRole()
  if (requiredRole === 'admin') {
    return userRole === 'admin'
  }
  return true
} 